package com.example.rest.service;

import com.example.rest.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

/**
 * @BelongsProject: RestTemplate
 * @BelongsPackage: com.example.rest.service
 * @Author:hlzs1
 * @Description: RestTemplate 的put请求
 * @CreateTime: 2023-03-01 10:05
 * @Version: 1.0
 */
@Service
public class PutService {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * @description: restTemplate的put请求
     * @author: haolizhuo
     * @date: 2023/3/2
     * @param: []
     * @return: void
     **/
    public void  put(){
        String url ="http://localhost:8090/restTemplate/hello3";
        Map<String ,Object> map = new HashMap<>(16);
        map.put("name","郝立琢map的Put请求");
        restTemplate.put(url,map);
    }


    /**
     * @description: restTemplate的put请求,json传参
     * @author: haolizhuo
     * @date: 2023/3/2
     * @param: []
     * @return: void
     **/
    public void  put2(){
        String url ="http://localhost:8090/restTemplate/hello3";
        UserModel userModel = new UserModel();
        userModel.setName("郝立琢json的Put请求");
        restTemplate.put(url,userModel);
    }


}
